<%
layout("/layouts/platform.html"){
%>
<script src="${base}/assets/plugins/moment.min.js"></script>
<style>
    .loglevel span {
        float:left;
        padding-top: 5px;
        padding-left: 5px;
    }
</style>
<div class=panel-body style="padding-top: 50px;">
    * 完整功能请切换到Vue版本

    <div id="showDiv" style="padding-top: 20px;"></div>
</div>
<script language="JavaScript">
    var tableData={};
    var formData={};
    function formatUptime(val) {
        var up=moment(val*1000);
        var now=moment();
        var hours=now.diff(up,'hours');
        var minutes=now.diff(up,'minutes')%60;
        var seconds=now.diff(up,'seconds')%60;
        return hours+"小时"+minutes+"分钟"+seconds+"秒";
    }
    function showData() {
        var str="";
        for(var item in tableData){
            str=str+"<ul>";
            str=str+"实例名:"+item;
            for(var index=0;index<tableData[item].length;index++){

                str=str+"<li>";
                str=str+" 进程ID:"+tableData[item][index].processId;
                str=str+" 日志等级:"+tableData[item][index].loglevel;
                str=str+" 运行时间:"+formatUptime(tableData[item][index].uptime);
                str=str+"   JVM";
                str=str+" Total:"+tableData[item][index].vmTotal+"MB";
                str=str+" Use:"+tableData[item][index].vmUse+"MB";
                str=str+" Free:"+tableData[item][index].vmFree+"MB";
                str=str+" Max:"+tableData[item][index].vmMax+"MB";
                str=str+"</li>";
            }
            str=str+"</ul>";
        }
        $("#showDiv").html(str);
    }
    function pageData() {//加载分页数据
        $.post(base + "/platform/sys/monitor/data", {}, function (data) {
            if (data.code == 0) {
                tableData = data.data;
                showData();
            } else {
                Toast.error(data.msg);
            }
        }, "json");
    }
    function doLoglevel() {
        $.post(base + "/platform/sys/monitor/loglevel", formData, function (data) {
            if (data.code == 0) {
                Toast.success(data.msg);
                pageData();
            } else {
                Toast.error(data.msg);
            }
        }, "json");
    }
    pageData();
</script>
<%}%>